import websocket
import threading
import time

# 定义 WebSocket 服务器的地址
ws_url = 'ws://172.16.108.224:30000/appengine/api/jober/v1/api/ws/31f20efc7e0848deab6a6bc10fc3021e/app/2ab8ce4a875a4f209aea1be82b1b4baa'


# 当连接成功打开后，定义要发送的消息
message = "Hello, Server!"


# 定义接收服务器消息的回调函数
def on_message(ws, message):
    print("Received from server: %s" % message)


# 连接 WebSocket 服务器
if __name__ == "__main__":
    websocket.enableTrace(True)  # 打印日志信息，调试时使用
    ws = websocket.WebSocketApp(ws_url, on_message=on_message, on_error=on_error)
    ws.run_forever()